/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
*/

package com.jinhe.tss.core.cachepool.container;

import com.jinhe.tss.core.cachepool.proxy.ProxyContainer;
import com.jinhe.tss.core.util.BeanUtil;


/**
 * <p>
 * ContainerFactory.java
 * </p>
 * 池容器工厂类，负责生成ProxyContainer包裹的容器代理类。
 * 
 * @author Jon.King 2007-1-9
 */

public class ContainerFactory {
    private static ContainerFactory factory = null;

    private ContainerFactory() {
    }

    public static ContainerFactory getInstance() {
        if (factory == null) {
            factory = new ContainerFactory();
        }
        return factory;
    }

    public IPoolContainer create(String className, String containerName) {
        Object instance = BeanUtil.newInstanceByName(
                className,
                new Class[] { String.class }, 
                new Object[] { containerName });
        
        return (IPoolContainer) ProxyContainer.wrap(instance);
    }
}
